<?php

$current_page = 'edit_product';

include 'inc_header.php';
include 'inc_menu.php';

// Redirect if User is not logged on
if(!isset($_SESSION["username"]))
{
	header("location: index.php");
}

// Insert Products and Options
if(isset($_POST['insertsupplier']))
{
	$connection = new DAOmySQLi();
	$connection->insertSupplier();
}

if(isset($_POST['insertstatus']))
{
	$connection = new DAOmySQLi();
	$connection->insertStatus();
}

if(isset($_POST['insertoptionvalue']))
{
	$connection = new DAOmySQLi();
	$connection->insertOptionValue();
}

if(isset($_POST['insertoptiontype']))
{
	$connection = new DAOmySQLi();
	$connection->insertOptionType();
}

if(isset($_POST['insertproductoptionvalue']))
{
	$connection = new DAOmySQLi();
	$connection->insertProductOptionValue();
}

if(isset($_POST['insertproductoption']))
{
	$connection = new DAOmySQLi();
	$connection->insertProductOption();
}

if(isset($_POST['insertproduct']))
{
	$connection = new DAOmySQLi();
	$connection->insertProduct();
}

if(isset($_POST['insertcategory']))
{
	$connection = new DAOmySQLi();
	$connection->insertCategory();
}


// Delete Products and Options
if(@$_REQUEST['action']=="delsupplier")
{
	$connection = new DAOmySQLi();
	$connection->deleteSupplier();
}

if(@$_REQUEST['action']=="delstatus")
{
	$connection = new DAOmySQLi();
	$connection->deleteStatus();
}

if(@$_REQUEST['action']=="deloptiontype")
{
	$connection = new DAOmySQLi();
	$connection->deleteOptionType();
}

if(@$_REQUEST['action']=="deloptionvalue")
{
	$connection = new DAOmySQLi();
	$connection->deleteOptionValue();
}

if(@$_REQUEST['action']=="delproductoption")
{
	$connection = new DAOmySQLi();
	$connection->deleteProductOption();
}

if(@$_REQUEST['action']=="delproductoptionvalue")
{
	$connection = new DAOmySQLi();
	$connection->deleteProductOptionValue();
}

if(@$_REQUEST['action']=="delcategory")
{
	$connection = new DAOmySQLi();
	$connection->deleteCategory();
}

if(@$_REQUEST['action']=="delproduct")
{
	$connection = new DAOmySQLi();
	$connection->deleteProduct();
}
?>

<div id="main">
	<div class="ym-wrapper">
		<div class="ym-wbox">

		<?php
		//Open Connection
		$connection = new DAOmySQLi();
		?>

			<!-- Show jQuery Tabs -->
			<div class="jquery_tabs">
			
				<h4>Product</h4>
				<div class="tabbody">
				<button class="ym-button ym-add toggle">hinzufügen</button>
				<div class="insert" style="display: none" >
				
					<form class="ym-form ym-columnar linearize-form" action=edit_product.php method=post enctype=multipart/form-data>
						<div class="ym-fbox-text">
							<label for="supplID">SupplierID:</label>	
							<?php $connection->getDropdown_supplID_Product(); ?>
						</div>
						<div class="ym-fbox-text">
							<label for="catID">CategoryID:</label>	
							<?php $connection->getDropdown_catID_Product(); ?>
						</div>
						<div class="ym-fbox-text">
							<label for="prodName">Product Name:</label> <input type="text" name="prodName" id="insert-text" value="" />
						</div>
						<div class="ym-fbox-text">
							<label for="prodDescriptionShort">Product Description Short:</label>
							<textarea name="prodDescriptionShort" id="insert-text" cols="30" rows="7"></textarea>
						</div>
						<div class="ym-fbox-text">
							<label for="prodDescription">Product Description:</label>
							<textarea name="prodDescription" id="insert-text" cols="30" rows="7"></textarea>
						</div>
						<div class="ym-fbox-text">
							<label for="prodImage">Product Image:</label>
							<input type="file" name="datei" size="53" />
						</div>
						<div class="ym-fbox-text">
							<label for="catID">StatusID:</label>	
							<?php $connection->getDropdown_statusID_Product(); ?>
						</div>
						<div class="ym-fbox-text">
							<label for="prodActive">Product Active:</label>
							<select name="prodActive" size="1" id="insert-dropdown">
								<option value="1">Ja</option>
								<option value="0">Nein</option>
							</select>
						</div>
						<div class="ym-fbox-text">
							<label for="prodMRSP">Product MRSP:</label>
							<input type="text" name="prodMRSP" id="insert-text" value="" />
						</div>
						<div class="ym-fbox-text">
							<label for="prodPrice">Product Price:</label>
							<input type="text" name="prodPrice" id="insert-text" value="" />
						</div>
						<div class="ym-fbox-button">
							<button class="ym-button ym-add" type="submit" name="insertproduct" id="insert-button">Insert</button>
						</div>
					</form>
					
				</div>
				
				<!-- Get all Products in Database -->
				<?php $connection->getProduct(); ?>
				</div>
				
				
				

				<h4>Category</h4>
				<div class="tabbody">
				<button class="ym-button ym-add toggle">hinzufügen</button>
				<div class="insert" style="display: none" >
				
					<form class="ym-form ym-columnar linearize-form" action=edit_product.php method=post enctype=multipart/form-data>
						<div class="ym-fbox-text">
							<label for="catID">Category Parent ID:</label>
							<?php $connection->getDropdown_catID_Category(); ?>
						</div>
						<div class="ym-fbox-text">
							<label for="catName">Category Name:</label>
							<input type="text" name="catName" id="insert-text" value="" />
						</div>
						<div class="ym-fbox-text">
							<label for="catActive">Category Active:</label>
							<select name="catActive" size="1" id="insert-dropdown">
								<option value="1">Ja</option>
								<option value="0">Nein</option>
							</select>
						</div>
						<div class="ym-fbox-text">
							<label for="catDescriptionShort">Category Description Short:</label>
							<textarea name="catDescriptionShort" id="insert-text" cols="30" rows="7"></textarea>
						</div>
						<div class="ym-fbox-text">
							<label for="catDescription">Category Description:</label>
							<textarea name="catDescription" id="insert-text" cols="30" rows="7"></textarea>
						</div>
						<div class="ym-fbox-text">
							<label for="catImage">Category Image:</label> <input type="file" name="datei" size="53" />
						</div>
						<div class="ym-fbox-button">
							<button class="ym-button ym-add" type="submit" name="insertcategory" id="insert-button">Insert</button>
						</div>
					</form>
					
				</div>
				
				<!-- Get all Categories from Database -->
				<?php $connection->getCategory(); ?>
				</div>




				<h4>Supplier</h4>
				<div class="tabbody">
				<button class="ym-button ym-add toggle">hinzufügen</button>
				<div class="insert" style="display: none" >
				
					<form class="ym-form ym-columnar linearize-form" action=edit_product.php method=post>
						<div class="ym-fbox-text">
							<label for="supplName">Supplier Name:</label>
							<input type="text" name="supplName" id="insert-text" value="" />
						</div>
						<div class="ym-fbox-text">
							<label for="supplActive">Supplier Active:</label>
							<select name="supplActive" size="1" id="insert-dropdown">
								<option value="1">Ja</option>
								<option value="0">Nein</option>
							</select>
						</div>
						<div class="ym-fbox-button">
							<button class="ym-button ym-add" type="submit" name="insertsupplier" id="insert-button">Insert</button>
						</div>
					</form>
					
				</div>
				
				<!-- Get all Suppliers from Database -->
				<?php $connection->getSupplier(); ?>
				</div>




				<h4>Product Option</h4>
				<div class="tabbody">
				<button class="ym-button ym-add toggle">hinzufügen</button>
				<div class="insert" style="display: none" >
				
					<form class="ym-form ym-columnar linearize-form" action=edit_product.php method=post>
						<div class="ym-fbox-text">
							<label for="prodID">Product ID:</label>
							<?php $connection->getDropdown_prodID_ProductOption(); ?>
						</div>
						<div class="ym-fbox-text">
							<label for="optionValue">Option Value:</label>
							<input type="text" name="optionValue" id="insert-text" value="" />
						</div>
						<div class="ym-fbox-text">
							<label for="prodOptRequired">Product Option Required:</label>
							<select name="prodOptRequired" size="1" id="insert-dropdown">
								<option value="1">Ja</option>
								<option value="0">Nein</option>
							</select>
						</div>
						<div class="ym-fbox-button">
							<button class="ym-button ym-add" type="submit" name="insertproductoption" id="insert-button">Insert</button>
						</div>
					</form>
					
				</div>
				
				<!-- Get all Product Options from Database -->
				<?php $connection->getProductOption(); ?>
				</div>




				<h4>Product Option Value</h4>
				<div class="tabbody">
				<button class="ym-button ym-add toggle">hinzufügen</button>
				<div class="insert" style="display: none" >
				
					<form class="ym-form ym-columnar linearize-form" action=edit_product.php method=post>
						<div class="ym-fbox-text">
							<label for="prodOptID">Product Option ID:</label>
							<?php $connection->getDropdown_prodOptID_ProductOptionValue(); ?>
						</div>
						<div class="ym-fbox-text">
							<label for="optValueID">Option Value ID:</label>
							<?php $connection->getDropdown_optValueID_ProductOptionValue(); ?>
						</div>
						<div class="ym-fbox-text">
							<label for="prodOptQuantity">Product Option Quantity:</label>
							<input type="text" name="prodOptQuantity" id="insert-text" value="" />
						</div>
						<div class="ym-fbox-text">
							<label for="prodOptPrice">Product Option Price:</label>
							<input type="text" name="prodOptPrice" id="insert-text" value="" />
						</div>
						<div class="ym-fbox-button">
							<button class="ym-button ym-add" type="submit" name="insertproductoptionvalue" id="insert-button">Insert</button>
						</div>
					</form>
						
				</div>
				
				<!-- Get all Product Option Values from Database -->
				<?php $connection->getProductOptionValue(); ?>
				</div>




				<h4>Option Value</h4>
				<div class="tabbody">
				<button class="ym-button ym-add toggle">hinzufügen</button>
				<div class="insert" style="display: none" >
				
					<form class="ym-form ym-columnar linearize-form" action=edit_product.php method=post>
						<div class="ym-fbox-text">
							<label for="optValueName">Option Value Name:</label>
							<input type="text" name="optValueName" id="insert-text" value="" />
						</div>
						<div class="ym-fbox-text">
							<label for="optionTypeID">Option Type ID:</label>
							<?php $connection->getDropdown_optionTypeID_OptionValue(); ?>
						</div>
						<div class="ym-fbox-button">
							<button class="ym-button ym-add" type="submit" name="insertoptionvalue" id="insert-button">Insert</button>
						</div>
					</form>
					
				</div>
				
				<!-- Get all Option Values from Database -->
				<?php $connection->getOptionValue(); ?>
				</div>




				<h4>Option Type</h4>
				<div class="tabbody">
				<button class="ym-button ym-add toggle">hinzufügen</button>
				<div class="insert" style="display: none" >
				
					<form class="ym-form ym-columnar linearize-form" action=edit_product.php method=post>
						<div class="ym-fbox-text">
							<label for="optType">Option Type:</label>
							<input type="text" name="optType" id="insert-text" value="" />
						</div>
						<div class="ym-fbox-text">
							<label for="optName">Option Name:</label>
							<input type="text" name="optName" id="insert-text" value="" />
						</div>
						<div class="ym-fbox-button">
							<button class="ym-button ym-add" type="submit" name="insertoptiontype" id="insert-button">Insert</button>
						</div>
					</form>	
					
				</div>
				
				<!-- Get all Option Types from Database -->
				<?php $connection->getOptionType(); ?>
				</div>




				<h4>Status</h4>
				<div class="tabbody">
				<button class="ym-button ym-add toggle">hinzufügen</button>
				<div class="insert" style="display: none" >
				
					<form class="ym-form ym-columnar linearize-form" action="edit_product.php" method="post">
						<div class="ym-fbox-text">
							<label for="statusName">Status Name:</label>
							<input type="text" name="statusName" id="insert-text" value="" />
						</div>
						<div class="ym-fbox-text">
							<label for="statusColor">Status Color:</label> 
							<input type="text" name="statusColor" id="insert-text" value="" />
						</div>
						<div class="ym-fbox-button">
							<button class="ym-button ym-add" type="submit" name="insertstatus" id="insert-button">Insert</button>
						</div>
					</form>	
					
				</div>
				
				<!-- Get all Status from Database -->
				<?php $connection->getStatus(); ?>
				</div>
				
			</div>
			
			<!-- Toggle Insert Menus with jQuery -->
			<script>
				$(".toggle").click(function () {
					$(".insert").slideToggle("slow");
				});
			</script> 
			
		</div>
	</div>
</div>


<?php
include 'inc_footer.php';
?>